package one.stand.controller;

import one.stand.model.Dynamic;
import one.stand.model.ResultModel;
import one.stand.request.*;
import one.stand.response.CompanyResponse;
import one.stand.service.DynamicService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("company")
public class CompanyController extends BaseController {

    @Autowired
    private DynamicService dynamicService;

    /**
     * 获取企业信息
     *
     * @param request
     * @return
     */
    @PostMapping("getCompany")
    public ResultModel<CompanyResponse> getCompany(@RequestBody CompanyRequest request) {
        return companyService.getCompany(request);
    }

    /**
     * 获取企业信息
     *
     * @param request
     * @return
     */
    @PostMapping("getCompanyId")
    public ResultModel<CompanyResponse> getCompanyId(@RequestBody CompanyRequest request) {
        return companyService.getCompanyId(request);
    }

    /**
     * 查询公司信息
     */
    @PostMapping("getCompanyAllInfo")
    public ResultModel getCompanyAllInfo(@RequestBody CompanyRequest request) {
        return companyService.getCompanyAllInfo(request);
    }

    /**
     * 企业邀请
     *
     * @param request
     * @return
     */
    @PostMapping("invitation")
    public ResultModel<CompanyResponse> invitation(@RequestBody CompanyRequest request) {
        return companyService.invitation(request);
    }

    /**
     * 添加/修改公司动态/文章
     *
     * @param request
     * @return
     */
    @PostMapping("addDynamicInfo")
    public ResultModel addDynamicInfo(@RequestBody DynamicRequest request) {

        Dynamic model = new Dynamic();
        BeanUtils.copyProperties(request, model);
        model.setCompanyId(request.getCId().intValue());
        model.setCreateUserId(request.getId().intValue());
        dynamicService.addDynamicInfo(model);
        return ResultModel.success();
    }

    /**
     * 删除公司动态/文章
     *
     * @param request
     * @return
     */
    @PostMapping("delDynamicInfo")
    public ResultModel delDynamicInfo(@RequestBody DynamicRequest request) {
        dynamicService.delDynamicInfo(request.getDynamicId(), request.getId().intValue());
        return ResultModel.success();
    }

    /**
     * 添加/修改公司官网信息
     *
     * @param request
     * @return
     */
    @PostMapping("addWebsiteInfo")
    public ResultModel addWebsiteInfo(@RequestBody WebsiteRequest request) {
        return companyService.addWebsiteInfo(request);
    }

    /**
     * 查询公司招聘信息
     *
     * @param request
     * @return
     */
    @PostMapping("selectCompanyRecruit")
    public ResultModel selectCompanyRecruit(@RequestBody CompanyRecruitRequest request) {
        return companyService.selectCompanyRecruit(request);
    }

    /**
     * 添加/修改公司招聘信息
     *
     * @param request
     * @return
     */
    @PostMapping("addCompanyRecruit")
    public ResultModel addCompanyRecruit(@RequestBody CompanyRecruitRequest request) {
        return companyService.addCompanyRecruit(request);
    }

    /**
     * 添加招聘HR电话
     *
     * @param request
     * @return
     */
    @PostMapping("addHrPhone")
    public ResultModel addHrPhone(@RequestBody CompanyRequest request) {
        return companyService.addHrPhone(request);
    }

    /**
     * 删除公司招聘信息
     *
     * @param request
     * @return
     */
    @PostMapping("delCompanyRecruit")
    public ResultModel delCompanyRecruit(@RequestBody CompanyRecruitRequest request) {
        return companyService.delCompanyRecruit(request);
    }

    /**
     * crmPC-支付
     */
    @PostMapping("/payment")
    public ResultModel<String> payment(@RequestBody CompanyAccountRequest request) {
        return companyService.payment(request);
    }

    /**
     * 回调
     */
    @PostMapping("/backPayMent")
    public String backPayMent(@RequestParam String request) {
        return companyService.backPayMent(request);
    }
}
